Skip to content

Add an integration test for the Network screen#9003

Merged
srawlins merged 5 commits into
flutter:masterfrom
srawlins:network-integration
Mar 10, 2025
Merged

Add an integration test for the Network screen#9003
srawlins merged 5 commits into
flutter:masterfrom
srawlins:network-integration

Conversation

@srawlins
Copy link
Copy Markdown
Contributor

@srawlins srawlins commented Mar 7, 2025

There's a lot to this change!

I wanted precise control over when the "test app" makes requests, and what kind, etc. I've added a capability for a Dart test app to print out what port it's "control server" is listening to, very similar to how it prints out the URL for DevTools to connect to.

The "control server" is a basic HTTP server, that can be controlled with very simple requests. In this case, when the server sees a request to '/get/', it calls a dart:io HttpClient to send an HTTP GET request. A request to '/post/' directs the HttpClient to send an HTTP POST request, etc.

For the network screen tests to see complete requests, there is a second HTTP server that responds to the test requests.

So some changes are made to TestDartCliApp to support the "control port". This int is then passed to the integration test in the 'test args' (see the changes to integration_test/test_infra/run/run_test.dart).

OK, then the test itself: This test is simple for now. The following types of requests are validated:

  • dart:io HttpClient GET
  • dart:io HttpClient POST
  • dart:io HttpClient PUT
  • dart:io HttpClient DELETE
  • Dio GET
  • Dio POST

There are some TODOs for other requests we want to validate.

Work towards #7554.

@srawlins srawlins requested a review from a team as a code owner March 7, 2025 21:53
@srawlins srawlins requested review from kenzieschmoll and removed request for a team March 7, 2025 21:53
Comment thread packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart Outdated
Comment thread packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart Outdated
Comment thread packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart Outdated
Comment on lines +87 to +89
final client = io.HttpClient();

final _dio = Dio();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do any of these http clients need to be closed at some point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I haven't seen a need to close them. Is there a point in the test lifecycle that I can? Like, in tearDown I could send a request to exit the process.

Copy link
Copy Markdown
Contributor Author

@srawlins srawlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!

Comment thread packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart Outdated
Comment thread packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart Outdated
Comment thread packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart Outdated
Comment on lines +87 to +89
final client = io.HttpClient();

final _dio = Dio();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I haven't seen a need to close them. Is there a point in the test lifecycle that I can? Like, in tearDown I could send a request to exit the process.

@kenzieschmoll
Copy link
Copy Markdown
Member

Hmm, I haven't seen a need to close them. Is there a point in the test lifecycle that I can? Like, in tearDown I could send a request to exit the process.

Tear down would be a good place. I was wondering if we might see the test app process hang without closing these down.

@srawlins srawlins merged commit 40b2a26 into flutter:master Mar 10, 2025
@srawlins srawlins deleted the network-integration branch March 10, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants